<template>
	<view class="wrap">
		<u-swiper :list="imgList" :height="150" @click="imgListClick"></u-swiper>
		<view class="workbench-title">常用应用</view>
		<view class="toolbar">
			<u-grid class="grid" :col="4" :border="false">
        <u-grid-item  @click="navTo(item.url)"  v-for="(item, index) in commonApp" :key="index">
					<view :class="'home-icon '+item.iconColor">
						<i :class="'iconfont '+item.icon" :style="item.style"></i>
					</view>
					<u--text :text="item.name" type="info" align="center" size="14" lineHeight="50"></u--text>
        </u-grid-item>
			</u-grid>
		</view>
    <u-gap height="10"></u-gap>
    <u-sticky bgColor="#FFFFFF">
      <view class="workbench-title">全部应用</view>
      <u-tabs :list="list1" @click="click"></u-tabs>
    </u-sticky>
    <u-gap height="10"></u-gap>
    <u-line color="#606266"></u-line>
    <u-gap height="20"></u-gap>
		<view class="toolbar">
			<u-grid class="grid" :col="4" :border="false">
				<u-grid-item @click="navTo(item.url)" v-for="(item, index) in appData" :key="index">
					<view :class="'home-icon '+item.iconColor">
						<i :class="'iconfont '+item.icon"></i>
					</view>
          <u--text :text="item.name" type="info" align="center" size="14" lineHeight="50"></u--text>
				</u-grid-item>
			</u-grid>
		</view>
    <u-gap	height="200px"></u-gap>
    <u-back-top :scroll-top="scrollTop" top="0"></u-back-top>
		<u-divider text="已经到底了"></u-divider>
	</view>

</template>
<script>

/**
 * Copyright (c) 2020-Now http://www.future.com All rights reserved.
 */
const ossBase = 'https://ff-cloud.oss-cn-beijing.aliyuncs.com'
import { workbenchIndex } from '@/api/component'
export default {
	data() {
		return {
      workbenchData:[],
      appData: [],
      commonApp: [],
			show: false,
			imgList: [	ossBase+'/app/future/banner/banner-01.png',	ossBase+'/app/future/banner/banner-01.png',	ossBase+'/app/future/banner/banner-01.png'],
      list1: [{name: '流调通' }, { name: '小功能'}, { name: '硬件'}, { name: '办公'}, {  name: '娱乐' }],
      currIndex: 0,
      scrollTop: 0
		};
	},
  onPageScroll(e) {
		this.scrollTop = e.scrollTop;
	},
  created(){
    workbenchIndex({params: {}, custom: { auth: false,toast: false }}).then(response => {
      this.workbenchData = response.data
      this.appData = this.workbenchData.allApp['0']
      this.commonApp = this.workbenchData.commonApp
    })
  },
	methods: {
		navTo(url) {
			uni.navigateTo({url: url});
		},
		imgListClick(index) {
			console.log(`点击了第${index + 1}页图片`)
		},
    click(item) {
      this.currIndex = item.index
      this.appData = this.workbenchData.allApp[this.currIndex]
    }
	}
};
</script>
<style lang="scss">
  @import 'index.scss';

</style>
